# encoding: utf-8

import json


with open("./data_default_zkh_sku_info.json", "r", encoding="utf-8") as f:
    datas = json.load(f)["RECORDS"]

result = []

for data in datas:
    skuId = data.get("skuId")
    main_str = data.get("mainImages")
    detail_str = data.get("detailImages")
    if main_str:
        main_images = json.loads(main_str)
    else:
        main_images = []
    if detail_str:
        detail_images = json.loads(detail_str)
    else:
        detail_images = []

    d = {
        "skuId": skuId,
        "mainImages": main_images,
        "detailImages": detail_images
    }
    result.append(d)

with open("zkh_datas.txt", "w", encoding="utf-8") as f:
    for data in result:
        f.write(json.dumps(data, ensure_ascii=False)+"\n")



